function iframeSendImageForm($scope) {
	$('#image-upload-form').iframePostForm({
		json : true,
		complete : function (response) {
			var style, width, html = '';
			if (response.success)
			{
				console.log("Upload successful! Sending image with id:" + response.photoId);
				$scope.$apply(function() {
					$scope.sendImageOver(response.photoId, response.description);
				});
								
			} else {
				console.log("Failed to upload image!");
			}
		}
	});
};

function iframeProfileImageForm() {
	$('#profile-upload-form').iframePostForm({
		json : true,
		post : function () {
		},
		complete : function (response) {
			var style, width, html = '';
			if (response.success) {
				console.log("Upload successful! image id:" + response.photoId);
				$('#profileImagePopup').bPopup().close();
			} else {
				console.log("Failed to upload image!");
				console.log(response.message);
			}
		}
	});
};




function fitImgToWindow(img){
	
	  var imgWidth = img.width,
	  imgHeight = img.height,
	  winWidth = $(window).width(),
	  winHeight = $(window).height(),
	  ratio = Math.min(winWidth/imgWidth, winHeight/imgHeight);
	  
	  if (imgHeight > winHeight || imgWidth > winWidth) {
		  $(img).css({width:imgWidth*ratio, height:imgHeight*ratio});		  
	  }
};
